
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1">
		<link rel="stylesheet" href="./css/reset.css">
		<link rel="stylesheet" href="./css/common.css">
		<link rel="stylesheet" href="./css/login.css">
		<link rel="stylesheet" type="text/css" href="js/jquery.js"/>
		<link rel="stylesheet" href="plugins/font-awesome-4.7.0/css/font-awesome.min.css">
			
		<script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
			
			<script>
				$(function(){
					//<div class="button-login">
			 
					$("div.button-login").on("click",function(){
						
						var loginName = $("input[name='loginName']").val();
						var password = $("input[name='password']").val();
						
						
						//发送登录请求
						$.ajax({
							type:"POST",
							url:"http://192.168.150.202:8080/Api/customers",
							data:"loginName="+loginName+"&password="+password,
							success:function(responseData){ //{"success":false,"msg":"xx"}
								if(responseData.success){
									
									//获取到当前顾客的信息.保存到localStorage //map
									 console.log(responseData);
									 console.log(responseData.rows);
									
									//json对象-->json字符串
									//JSON
									    //stringify    json对象-->json字符串
										//parse        json字符串-->json对象
									   
									  
									localStorage.setItem("info", JSON.stringify(responseData.rows));
									window.location.href="http://127.0.0.1:8848/Canteen/payment.html";
								}else{
									
									alert(responseData.msg);
								}
							}
						});
					});
					
				});
			</script>
		<title>用户登陆</title>
	</head>
	<body>
		<div class="footer">
		    <ul>
			    <a href="index.html"><li><i class="fa fa-home"></i>首页</li></a>
			    <a href="shop.html"><li><i class="fa fa-chrome"></i>店铺</li></a>
			    <a href="order.html"><li><i class="fa fa-tasks"></i>订单</li></a>
			    <a href="mine.html"><li><i class="fa fa-user-o"></i>我的</li></a>
		    </ul>
		</div>
		<div class="wrapper">
			
			<!-- header部分 -->
			<header>
				<p>用户登陆</p>
			</header>
			
			<!-- 表单部分 -->
			<ul class="form-box">
				<li>
					<div class="title">
						账号：
					</div>
					<div class="content">
						<input type="text" name="loginName" placeholder="账号">
					</div>
				</li>
				<li>
					<div class="title">
						密码：
					</div>
					<div class="content">
						<input type="password" name="password" placeholder="密码">
					</div>
				</li>
			</ul>
			
			<div class="button-login">
				<button>登陆</button>
			</div>
			<div class="button-login">
				<a href="register.html"><button>注册</button></a>
			</div>
		    
		</div>
	</body>
</html>
